package leetcode.violence;

import java.util.ArrayList;
import java.util.List;

public class Perm {
    public static void main(String[] args) {
        String str = "1234";
        char[] chars = str.toCharArray();
        permProcess(chars,0,chars.length-1);
    }
    public static void permProcess(char[] arr,int a,int b){
        if (a==b){
            for (char i: arr) {
                System.out.print(i);
            }
            System.out.println();
        }else {
            for (int i = a; i <=b; i++) {
                swap(arr, a, i);
                permProcess(arr, a+1, b);
                swap(arr, a, i);
            }
        }

    }
    public static void swap(char[] arr,int a,int b){
        char temp = arr[a];
        arr[a] = arr[b];
        arr[b] = temp;
    }
}
